package GUIadapter;

import java.util.List;

import javax.swing.table.AbstractTableModel;

import ModelLayer.Supplier;

@SuppressWarnings("serial")
public class SupplierModel extends AbstractTableModel
{
	private final String[] columnHeader = {"Firma","Telefon","Kreditornummer"};

	private List<Supplier> supplierList;

	public SupplierModel(List<Supplier> supplierList)
	{
		this.supplierList = supplierList;
	}

	@Override
	public String getColumnName(int column)
	{
		// TODO Auto-generated method stub
		return columnHeader[column];
	}

	@Override
	public int getColumnCount()
	{
		// TODO Auto-generated method stub
		return columnHeader.length; // depends on amount of getters for a supplier
																// eg.: "getName()"... very ugly
	}

	@Override
	public int getRowCount()
	{
		// TODO Auto-generated method stub
		return supplierList.size();
	}

	@Override
	public Object getValueAt(int row, int col)
	{
		// TODO Auto-generated method stub
		Supplier supplier = supplierList.get(row);
		switch(col)
		{
		case 0:
			return supplier.getCompanyName();
		case 1:
			return supplier.getPhone();
		case 2:
			return new Integer(supplier.getCreditornr());
		}
		return null;
	}

} // end SupplierModel

